	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		<h4 class="modal-title" th:text="|为角色【XX】分配资源|"></h4>
	</div>
	
	<ul id="tree" class="ztree" style="width:560px; overflow:auto;"></ul>
	
	
	<div class="modal-footer">
		<button class="btn btn-primary" type="submit" onclick="tijiao()">
			<strong>提 交</strong>
		</button>
		<button type="button" class="btn btn-default" data-dismiss="modal">
			<strong>关 闭</strong>
		</button>
	</div>
<script th:inline="javascript">
    /*<![CDATA[*/
   var zTree;
    var demoIframe;
    var setting = {
        check: {
            enable: true
        },
        view: {
            dblClickExpand: false,
            showLine: true,
            selectedMulti: true
        },
        data: {
            simpleData: {
                enable:true,
                idKey: "id",
                pIdKey: "PId",
                rootPId: ""
            }
        },
        
    };
    var zNodes =/*[[${reslurceTree}]]*/;

    $(document).ready(function(){
        var t = $("#tree");
        t = $.fn.zTree.init(t, setting, zNodes);
    });

   
    function tijiao(){
        var treeObj = $.fn.zTree.getZTreeObj("tree");
        var nodes = treeObj.getCheckedNodes(true);
        var roleId =/*[[${roleId}]]*/;   //当前角色的id
        var resourcesId="";
        if(nodes.length>=2){
            for(var i=0;i<nodes.length-1;i++){
                resourcesId+=nodes[i].id+",";
            }
            resourcesId+=nodes[nodes.length-1].id;
        }else if(nodes.length==1){
            resourcesId+=nodes[nodes.length-1].id;
        }
        var parms={"resourceId":resourcesId,"id":roleId}
        var url= /*[[@{/admin/c/role/updateResourcesByRole.gsp}]]*/'url';
        //alert(nodes.length+"*****"+resourcesId);
        tg_simpleAjaxPost(url, parms, null, null);
    }

    /*]]>*/
</script>